﻿using System;
using System.Windows.Forms;
using Login.Model;
using Login.BLL;

namespace Courses
{
    public partial class tb_zhidingNoweek : Form
    {
        public tb_zhidingNoweek()
        {
            InitializeComponent();
        }
        public string id;   //跨界面的到班级ID

        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        #region
        private void tb_zhidingNoweek_Load(object sender, EventArgs e)
        {
            //通过班级ID找到对应班级
            UseModel use = tb_SweekBLL.getClassName(id);
            zhuanye.Text = use.banJi;
            //提取所有不上课周数
            string[] str = tb_SweekBLL.getWeeks(id);
            //遍历所有不上课周
            for (int i = 0; i < str.Length; i++)
            {
                //检索出对应的上课周方法
                bind(str[i]);
            }
        }
        #endregion

        /// <summary>
        /// 检索出对应的上课周方法
        /// </summary>
        /// <param name="zhouNum">周序号</param>
        #region
        public void bind(string zhouNum)
        {
            switch (zhouNum)
            {
                case "2":
                    dianJiOne.Checked = true;
                    break;
                case "3":
                    dianJiTwo.Checked = true;
                    break;
                case "4":
                    dianJiThree.Checked = true;
                    break;
                case "5":
                    dianJiFour.Checked = true;
                    break;
                case "6":
                    dianJiFive.Checked = true;
                    break;
                case "7":
                    dianJiSix.Checked = true;
                    break;
                case "8":
                    dianJiSeven.Checked = true;
                    break;
                case "9":
                    dianJiEight.Checked = true;
                    break;
                case "10":
                    dianJiNine.Checked = true;
                    break;
                case "11":
                    dianJiTen.Checked = true;
                    break;
                case "12":
                    dianJiEleven.Checked = true;
                    break;
                case "13":
                    dianJiTwelve.Checked = true;
                    break;
                case "14":
                    dianJiThirteen.Checked = true;
                    break;
                case "15":
                    dianJiFourteen.Checked = true;
                    break;
                case "16":
                    dianJiFifteen.Checked = true;
                    break;
            }
        }
        #endregion

        /// <summary>
        /// 按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        #region
        private void btn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("你确定此班级这些周不上课吗？", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                try
                {
                    //清空所有不上课周
                    tb_SweekBLL.UpdateEmpty(id);
                    //判断所有不上课选中事件
                    if (dianJiOne.Checked == true)
                    {
                        //不上课周存入
                        tb_SweekBLL.getcun(id, 2);
                    }
                    if (dianJiTwo.Checked == true) { tb_SweekBLL.getcun(id, 3); }
                    if (dianJiThree.Checked == true) { tb_SweekBLL.getcun(id, 4); }
                    if (dianJiFour.Checked == true) { tb_SweekBLL.getcun(id, 5); }
                    if (dianJiFive.Checked == true) { tb_SweekBLL.getcun(id, 6); }
                    if (dianJiSix.Checked == true) { tb_SweekBLL.getcun(id, 7); }
                    if (dianJiSeven.Checked == true) { tb_SweekBLL.getcun(id, 8); }
                    if (dianJiEight.Checked == true) { tb_SweekBLL.getcun(id, 9); }
                    if (dianJiNine.Checked == true) { tb_SweekBLL.getcun(id, 10); }
                    if (dianJiTen.Checked == true) { tb_SweekBLL.getcun(id, 11); }
                    if (dianJiEleven.Checked == true) { tb_SweekBLL.getcun(id, 12); }
                    if (dianJiTwelve.Checked == true) { tb_SweekBLL.getcun(id, 13); }
                    if (dianJiThirteen.Checked == true) { tb_SweekBLL.getcun(id, 14); }
                    if (dianJiFourteen.Checked == true) { tb_SweekBLL.getcun(id, 15); }
                    if (dianJiFifteen.Checked == true) { tb_SweekBLL.getcun(id, 16); }
                }
                catch (Exception)
                {
                    
                    throw;
                }
            }
            this.Close();
        }
        #endregion

    }
}
